// 引入路由
import Vue from "vue";
import VueRouter from "vue-router";

// 注册路由
Vue.use(VueRouter);

// 引入页面路由

import City from "@/views/City";
import Login from "@/views/Login";
import Map from "@/views/Map";
import Layout from "@/views/Layout";
import Management from "@/views/Management";
import Collection from "@/views/Collection";
import Detail from "@/views/Detail";

// 引入子路由
import List from "@/views/List";
import My from "@/views/My";
import News from "@/views/News";
import Home from "@/views/Home";
import Register from "@/views/Register";

// 配置路由规则
const routes = [
  {
    path: "/",
    redirect: "/layout",
  },
  {
    path: "/layout",
    component: Layout,
    redirect: "/layout/home",
    children: [
      {
        path: "home",
        component: Home,
      },
      {
        path: "list",
        component: List,
      },
      {
        path: "my",
        component: My,
      },
      {
        path: "news",
        component: News,
      },
    ],
  },
  {
    path: "/city",
    component: City,
  },
  {
    path: "/login",
    component: Login,
  },
  {
    path: "/map",
    component: Map,
  },
  {
    path: "/register",
    component: Register,
  },
  {
    path: "/collection",
    component: Collection,
  },
  {
    path: "/management",
    component: Management,
  },
  {
    name: "detail",
    path: "/detail/:houseCode?",
    component: Detail,
  },
];

// 生成路由对象并暴露
export default new VueRouter({
  routes,
});
